var ws = require('nodejs-websocket');
var port = 4000;
var server = ws.createServer(function(conn){
	console.log('New Connection');
	conn.on('text',function(str){
		console.log('Received' + str);
		conn.sendText(str.toUpperCase() + '!!!'); 
	});
	conn.on('close',function(code,reason){
		consloe.log('Connection closed');
	})
	conn.on('error',function(err){
		consloe.log('handle error');
		console.log(err);
	});
}).listen(port);
console.log('websocket server listeing on port' + port);